package com.sss.springcloud.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * gateway网关配置编码
 * @author sss
 * @date 2020-03-08 13:39
 **/
@Configuration
public class GateWayConfig {

    @Bean
     public RouteLocator customRouteLocator(RouteLocatorBuilder routeLocatorBuilder){
        RouteLocatorBuilder.Builder routes = routeLocatorBuilder.routes();
        routes.route("sss",r -> r.path("/guonei")//访问的地址
                //将转发的地址
                .uri("http://news.baidu.com/guonei")).build();
        return routes.build();

    }
}
